package com.chixing.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.chixing.entity.Coupon;
import com.chixing.mapper.CouponMapper;
import com.chixing.service.ICouponService;
import com.chixing.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author smith
 * @since 2025-05-21
 */

@Service
public class CouponServiceImpl implements ICouponService {
    @Autowired
    private CouponMapper couponMapper;


    @Override
    public Result getById(Integer couponId) {
        return null;
    }

    @Override
    public Result getAll() {
//select *from coupon
        QueryWrapper<Coupon> wrapper = new QueryWrapper<>();
        wrapper.gt("coupon_end_time", LocalDateTime.now());
        List<Coupon> couponList = couponMapper.selectList(wrapper);
        if(couponList !=null && couponList.size()>0)
            return Result.getSuccess(couponList);
        return Result.getFail("暂无优惠卷数据");
    }

}





